@implements IDisposable
@inject NavigationManager NavMan

<button @onclick="() => NavMan.NavigateTo(GoToUrl)"></button>
<p>@url</p>

@code {
	private string url;

	[Parameter] public string GoToUrl { get; set; } = string.Empty;

    protected override void OnInitialized()
		=> NavMan.LocationChanged += OnLocationChanged;

	public void Dispose()
		=> NavMan.LocationChanged -= OnLocationChanged;

    private	void OnLocationChanged(object? sender, LocationChangedEventArgs e)
	{
        url = e.Location;
        StateHasChanged();
	}
}
